import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
// import Layout from "@/layout";

export const constantRoutes = [
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true
  },
  {
    path: "/",
    redirect: "/choose-company"
  },
  {
    path: "/choose-company",
    component: () => import("@/views/choose-company/index"),
    hidden: true
  },
  {
    path: "/404",
    component: () => import("@/views/404"),
    hidden: true
  }
];
// 引用模块路由
import BaseScreenManageRouter from "./modules/BaseScreenManageRouter";
import LargeScreenConfigurableRouter from "./modules/LargeScreenConfigurableRouter";
import OrderManageRouter from "./modules/orderManageRouter";
import animalHusbandryRouter from "./modules/animalHusbandryRouter";
import agriculturalCulturalAndTourismRouter from "./modules/agriculturalCulturalAndTourismRouter";
import baseManageRouter from "./modules/baseManageRouter";
import baseTemplateManageRouter from "./modules/baseTemplateManageRouter";
import adminRouter from "./modules/adminRouter";
import FishSettingRouter from "./modules/fishSettingRouter";
import DiseaseLibraryRouter from "./modules/diseaseLibraryRouter";
// import sensitiveWordManageRouter from "./modules/sensitiveWordManageRouter";
// import adminConfigRouter from "./modules/adminConfigRouter";
import monitorRouter from "./modules/monitorRouter";
import socialRouter from "./modules/socialRouter";
import agriculturalSocialRouter from "./modules/agriculturalSocialRouter";

export const asyncRoutes = [
  // 基地大屏管理
  BaseScreenManageRouter,
  // 大屏配置
  LargeScreenConfigurableRouter,
  // {
  //   path: "external-link",
  //   component: Layout,
  //   children: [
  //     {
  //       path: "https://panjiachen.github.io/vue-element-admin-site/#/",
  //       meta: { title: "External Link", icon: "link" }
  //     }
  //   ]
  // },
  // 404 page must be placed at the end !!!
  { path: "*", redirect: "/404", hidden: true }
];
export const asyncSCRoutes = [
  // 订单管理
  baseManageRouter,
  baseTemplateManageRouter,
  // 畜牧
  animalHusbandryRouter,
  // 农文旅
  agriculturalCulturalAndTourismRouter,
  FishSettingRouter,
  DiseaseLibraryRouter,
  OrderManageRouter,
  // 404 page must be placed at the end !!!
  { path: "*", redirect: "/404", hidden: true }
];
export const asyncAdminRoutes = [
  ...adminRouter,
  // sensitiveWordManageRouter,
  // adminConfigRouter,
  { path: "*", redirect: "/404", hidden: true }

]
export const asyncMonitorRoutes = monitorRouter
export const asyncSocialRoutes = socialRouter
export const asyncAgriculturalSocialRoutes = agriculturalSocialRouter
// [
//   // 订单管理
//   adminRouter,
//   // 404 page must be placed at the end !!!
//   { path: "*", redirect: "/404", hidden: true }
// ];
const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  });

const router = createRouter();

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
